/**
 * 
 */
package org.arpit.masteringextjs.utility;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.arpit.masteringextjs.dao.impl.ActorDAOImpl;
import org.arpit.masteringextjs.dao.impl.CategoryDAOImpl;
import org.arpit.masteringextjs.dao.impl.CityDAOImpl;
import org.arpit.masteringextjs.dao.impl.CountryDAOImpl;
import org.arpit.masteringextjs.dao.impl.FilmDAOImpl;
import org.arpit.masteringextjs.dao.impl.GroupsDAOImpl;
import org.arpit.masteringextjs.dao.impl.LanguageDAOImpl;
import org.arpit.masteringextjs.dao.impl.UserDAOImpl;
import org.arpit.masteringextjs.domain.Actor;
import org.arpit.masteringextjs.domain.Category;
import org.arpit.masteringextjs.domain.City;
import org.arpit.masteringextjs.domain.Country;
import org.arpit.masteringextjs.domain.Film;
import org.arpit.masteringextjs.domain.Groups;
import org.arpit.masteringextjs.domain.Language;
import org.arpit.masteringextjs.domain.Menu;
import org.arpit.masteringextjs.domain.User;
import org.arpit.masteringextjs.enums.Rating;

/**
 * Utility class to create test database
 * @author arpit
 * 
 */
public class TableCreationUtility {
	public static void main(String[] args) {
		Groups groups = new Groups();
		groups.setName("admin");

		Menu menu1 = new Menu();
		menu1.setText("menu1");
		menu1.setIconCls("menu_admin");

		Menu menu2 = new Menu();
		menu2.setParent(menu1);
		menu2.setText("menu11");
		menu2.setIconCls("menu_groups");
		menu2.setClassName("panel");

		Menu menu3 = new Menu();
		menu3.setParent(menu1);
		menu3.setText("menu12");
		menu3.setIconCls("menu_users");
		menu3.setClassName("users");
		
		Menu menu4 = new Menu();
		menu4.setText("staticData");
		menu4.setIconCls("menu_staticdata");
		
		Menu menu5 = new Menu();
		menu5.setParent(menu4);
		menu5.setText("actors");
		menu5.setIconCls("menu_actor");
		menu5.setClassName("actorsgrid");
		
		Menu menu6 = new Menu();
		menu6.setParent(menu4);
		menu6.setText("categories");
		menu6.setIconCls("menu_category");
		menu6.setClassName("categoriesgrid");
		
		Menu menu7 = new Menu();
		menu7.setParent(menu4);
		menu7.setText("languages");
		menu7.setIconCls("menu_language");
		menu7.setClassName("languagesgrid");
		
		Menu menu8 = new Menu();
		menu8.setParent(menu4);
		menu8.setText("cities");
		menu8.setIconCls("menu_city");
		menu8.setClassName("citiesgrid");
		
		Menu menu9 = new Menu();
		menu9.setParent(menu4);
		menu9.setText("countries");
		menu9.setIconCls("menu_country");
		menu9.setClassName("countriesgrid");
		
		Menu menu10 = new Menu();
		menu10.setText("cms");
		menu10.setIconCls("menu_cms");
		
		Menu menu11 = new Menu();
		menu11.setParent(menu10);
		menu11.setText("films");
		menu11.setIconCls("menu_films");
		menu11.setClassName("filmsgrid");

		List<Menu> menus = new ArrayList<>();
		menus.add(menu1);
		menus.add(menu2);
		menus.add(menu3);
		menus.add(menu4);
		menus.add(menu5);
		menus.add(menu6);
		menus.add(menu7);
		menus.add(menu8);
		menus.add(menu9);
		menus.add(menu10);
		menus.add(menu11);

		groups.setMenus(menus);

		GroupsDAOImpl.getInstance().createGroups(groups);

		//========================================================================
		Groups group = new Groups();
		group.setId(1L);

		User user = new User();
		user.setGroups(group);
		user.setName("Loiane Groner");
		user.setUserName("loiane");
		user.setPassword("e10adc3949ba59abbe56e057f20f883e");
		user.setEmail("me@loiane.com");

		UserDAOImpl.getInstance().create(user);
		
		//========================================================================
		Actor actor1 = new Actor();
		actor1.setFirstName("Paresh");
		actor1.setLastName("Rawal");
		actor1.setLastUpdated(new Date());
		
		Actor actor2 = new Actor();
		actor2.setFirstName("Akshay");
		actor2.setLastName("Kumar");
		actor2.setLastUpdated(new Date());
		
		ActorDAOImpl.getInstance().create(actor1);
		ActorDAOImpl.getInstance().create(actor2);
		//========================================================================
		
		Category category1 = new Category();
		category1.setName("action");
		category1.setLastUpdated(new Date());
		
		Category category2 = new Category();
		category2.setName("comedy");
		category2.setLastUpdated(new Date());
		
		CategoryDAOImpl.getInstance().create(category1);
		CategoryDAOImpl.getInstance().create(category2);
		//========================================================================
		
		Country country1 = new Country();
		country1.setCountry("India");
		country1.setLastUpdated(new Date());
		
		Country country2 = new Country();
		country2.setCountry("USA");
		country2.setLastUpdated(new Date());
		
		Country india = CountryDAOImpl.getInstance().create(country1);
		Country usa = CountryDAOImpl.getInstance().create(country2);
		//========================================================================
		
		City city1 = new City();
		city1.setCity("Pune");
		city1.setLastUpdated(new Date());
		city1.setCountry(india);
		
		City city2 = new City();
		city2.setCity("Mumbai");
		city2.setLastUpdated(new Date());
		city2.setCountry(india);
		
		City city3 = new City();
		city3.setCity("New York");
		city3.setLastUpdated(new Date());
		city3.setCountry(usa);
		
		CityDAOImpl.getInstance().create(city1);
		CityDAOImpl.getInstance().create(city2);
		CityDAOImpl.getInstance().create(city3);
		//========================================================================
		
		Language language1 = new Language();
		language1.setName("Hindi");
		language1.setLastUpdated(new Date());
		
		Language language2 = new Language();
		language2.setName("English");
		language2.setLastUpdated(new Date());
		
		Language createdlanguage = LanguageDAOImpl.getInstance().create(language1);
		LanguageDAOImpl.getInstance().create(language2);
		//========================================================================
		
		Film film1 = new Film();
		film1.setDescription("Romantic Comedy");
		film1.setTitle("2 States");
		film1.setLanguage(createdlanguage);
		film1.setOrignalLanguage(createdlanguage);
		film1.setLastUpdated(new Date());
		film1.setRating(Rating.G);
		film1.setReleaseYear(2014);
		film1.setRentalDuration(4);
		film1.setRentalRate(3.9f);
		film1.setReplacementCost(75.5f);
		film1.setSpecialFeatures("Behind the Scenes");
		film1.setLength(110);
		
		Film film2 = new Film();
		film2.setDescription("Action thriller");
		film2.setTitle("Queen");
		film2.setLanguage(createdlanguage);
		film2.setOrignalLanguage(createdlanguage);
		film2.setLastUpdated(new Date());
		film2.setRating(Rating.PG13);
		film2.setReleaseYear(2014);
		film2.setRentalDuration(3);
		film2.setRentalRate(3.5f);
		film2.setReplacementCost(80);
		film2.setSpecialFeatures("Trailers,Commentaries,Behind the Scenes");
		film2.setLength(135);
		
		FilmDAOImpl.getInstance().create(film1);
		FilmDAOImpl.getInstance().create(film2);
		
		//========================================================================
		
	}
}
